package hsb.ruoyi.common.config;


import com.github.pagehelper.PageInterceptor;
import io.quarkus.runtime.Startup;
import org.apache.ibatis.session.SqlSessionFactory;

import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.interceptor.Interceptor;

/**
 * @author 胡帅博
 * @date 2023/1/1 17:00
 */
@Startup(Interceptor.Priority.APPLICATION)
@ApplicationScoped
public class MybatisConfig {

    @Inject
    SqlSessionFactory sqlSessionFactoryBuildItems;

    @PostConstruct
    public void initSqlSession() {

      //  Properties properties = new Properties();

//        properties.setProperty("sqlCacheClass", "hsb.learn.common.config.PageHelperCache");
//        properties.setProperty("msCountCache", "hsb.learn.common.config.PageHelperCache");
    //    properties.setProperty("helperDialect", "mysql");
        PageInterceptor pageInterceptor = new PageInterceptor();
    //    pageInterceptor.setProperties(properties);

        sqlSessionFactoryBuildItems.getConfiguration().addInterceptor(pageInterceptor);
        //System.out.println(1321333);
    }

}
